<template>
	<view class="content base-con-bg">
		<view class="search">
			<image class="icon" src="/static/image/search-icon.png" mode="aspectFit"></image>
			<input type="text" placeholder="搜索信息" v-model="title" @blur="search" />
		</view>
		<view class="list" v-if="checked===0">
			<view class="item" v-for="(item,index) in list3.records" :key="index+'a'" @click="goDetail(item)">
				<view class="title">{{item.title}}</view>
				<view class="info">
					<view></view>
					<view>{{item.updatedAt}}</view>
				</view>
			</view>
			<view class="base-no-data" v-if="!list3.records || list3.records.length===0">
				<view class="icon"></view>
				<view class="msg">暂无信息~ </view>
			</view>
		</view>
		<view class="list" v-else :class="{'base-no-data': !list2.records || list2.records.length===0}">
			<view class="item" v-for="(item,index) in list2.records" :key="index+'a'" @click="goDetail(item)">
				<view class="title">{{item.title}}</view>
				<view class="info">
					<view></view>
					<view>{{item.updatedAt}}</view>
				</view>
			</view>
			<view class="base-no-data" v-if="!list2.records || list2.records.length===0">
				<view class="icon"></view>
				<view class="msg">暂无备考复习信息~ </view>
			</view>
		</view>
		
		<!-- 客服 -->
		<servicePopup ref="service1" type="2"></servicePopup>
		
	</view>
</template>

<script>
	import {exams} from "@/api/index.js"
	import servicePopup from '@/components/servicePopup.vue'
	export default {
		components: {
		  servicePopup,
		},
		data() {
			return {
				checked: 0,
				list1: [],
				list2: [],
				list3: {},
				title: '',
			}
		},
		onLoad(options) {
			this.getExams(options.type);//考试动态
		},
		onShareAppMessage(){
			return {
			    title: '陶老师课程',
			}
		},
		onShareTimeline(){
			return {
			    title: '陶老师课程',
			}
		},
		methods: {
			search(){
				if(this.checked===0){
					this.list3={};
					this.getExams('3');//考试动态
				}else{
					this.list2=[];
					this.getExams('2');//备考复习
				}
			},
			getExams(type){
				exams({
					type,
					title: this.title,
					page: 1,
					size: 100
				}).then(res=>{
					this.list3=res.data;
				})
			},
			goDetail(item){
				console.log(item,'-------146')
				if(item.show=='2'){//自定义内容
					this.$store.commit('set', ['noticeDetail',item]);
					uni.navigateTo({
						url: `/pages/noticeDetail2/index`,
					})
				}else if(item.show=='1'){//推文链接
					uni.navigateTo({
						url: '/pagesD/webView/index?url='+encodeURIComponent(item.url)
					})
				}else if(item.type==2){//小程序地址
					// #ifdef MP-WEIXIN
					wx.navigateToMiniProgram({
						appId: 'wx911aceb2827f8f8c',
						shortLink: item.url,
						// envVersion: 'develop',//develop开发版  trial体验版  release正式版
					})
					// #endif
					// #ifndef MP-WEIXIN
					uni.showToast({title: '暂不支持',icon: 'error'})
					// #endif
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		padding-top: 20rpx;
	}
	.tab{
		display: flex;
		align-items: center;
		justify-content: center;
		height: 86rpx;
		background-color: #fff;
		font-size: 30rpx;
		color: #505050;
		.tab-item{
			position: relative;
			&:first-child{
				margin-right: 184rpx;
			}
			&::after{
				display: none;
				content: "";
				position: absolute;
				left: 50%;
				bottom: -14rpx;
				width: 64rpx;
				height: 6rpx;
				margin-left: -32rpx;
				background-color: #6A8AE7;
				border-radius: 4rpx;
			}
			&.on{
				color: #6A8AE7;
				&::after{
					display: block;
				}
			}
		}
	}
	.list{
		padding: 32rpx 28rpx;
		line-height: 38rpx;
		font-weight: 500;
		.item{
			padding: 22rpx 24rpx 30rpx 40rpx;
			margin-bottom: 36rpx;
			background-color: #fff;
			box-shadow: 0rpx 0rpx 12rpx rgba(0,0,0,0.16);
			border-radius: 12rpx;
		}
		.title{
			margin-bottom: 14rpx;
			font-size: 30rpx;
			color: #303030;
		}
		.info{
			display: flex;
			justify-content: space-between;
			font-size: 24rpx;
			color: #9DA0A7;
		}
	}
	.search{
		position: relative;
		display: flex;
		align-items: center;
		height: 72rpx;
		margin: 0 12rpx 32rpx;
		font-size: 32rpx;
		input{
			flex: 1;
			height: 100%;
			padding-left: 94rpx;
			border-radius: 36rpx;
			background-color: #EBF2FF;
		}
		::v-deep .input-placeholder{
			color: #9D9D9D;
		}
		.icon{
			position: absolute;
			left: 44rpx;
			width: 28rpx;
			height: 28rpx;
			margin-right: 22rpx;
		}
	}
</style>
